package com.ruoyi.advertising.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitAdvertisingConfig {
    @Bean
    public Exchange advertisingExchange(){
        return ExchangeBuilder.topicExchange("advertising_exchange").durable(true).build();
    }
    @Bean
    public Queue advertisingQueue(){
        return QueueBuilder.durable("advertising_queue")
                .deadLetterExchange("advertising_dlx_exchange")
                .deadLetterRoutingKey("advertising.dlx.cancel ")
                .ttl(864000 * 1000).build();
    }
    @Bean
    public Binding bindingAdvertisingNormal() {
        return BindingBuilder.bind(advertisingQueue())
                .to(advertisingExchange())
                .with("advertising.#").noargs();
    }
    @Bean
    public Exchange advertisingDlxExchange() {
        return ExchangeBuilder.topicExchange("advertising_dlx_exchange")
                .durable(true).build();
    }
    @Bean
    public Queue advertisingDlxQueue() {
        return QueueBuilder.durable("advertising_dlx_queue").build();
    }
    @Bean
    public Binding bindingAdvertisingDlx() {
        return BindingBuilder.bind(advertisingDlxQueue())
                .to(advertisingDlxExchange())
                .with("advertising.dlx.#").noargs();
    }
}
